<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <title th:text="${question.title} + ' - Q & A'"></title>
        <head th:insert="~{import :: head}"></head>
        <head th:insert="~{import :: markdown}"></head>
        <link rel="stylesheet" href="/css/question.css">

    </head>
    <body>
        <div th:insert="navigation :: nav"></div>


        <div class="container-fluid main">
            <div class="row">
                <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12 question-lift">
                    <!--正文-->
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-left-l">

                        <h2><span th:text="${question.title}"></span></h2>

                        <span class="question-text-desc">
                            作者: <span th:text="${question.user.name}"></span> |
                            发布时间: <span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span> |
                             阅读数: <span th:text="${question.getViewCount()}"></span>
                            </span>

                        <hr class="question-hr">

                        <!-- 内容  -->
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-matter" id="question-view">
                            <textarea style="display:none;" th:text="${question.description}"></textarea>
                        </div>
                        <script type="text/javascript">
                            $(function () {
                                editormd.markdownToHTML("question-view", {});
                            });
                        </script>

                        <hr class="question-hr">
                        <!-- 标签 -->
                        <span class="label label-info question-tags " th:each="tag : ${question.tag.split(',')}">
                            <span class="glyphicon glyphicon-tags"></span>
                              <span class="label label-info " th:text="${tag}"></span>
                            </span>
                        <hr class="question-hr">
                        <a th:href="@{'/publish/'+${question.id}}" class="question-menu"
                           th:if="${session.user !=null && session.user.id == question.creator}">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                            编辑
                        </a>
                        <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    </div>

                    <h3 class="question-count">
                        <span th:text="${question.commentCount}"></span>个回复
                    </h3>
                    <!-- 回复 -->
                    <hr class="question-hr">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-left-Reply"
                         th:each="comment : ${comments}">

                        <div class="media question-media">
                            <div>
                                <div class="media-left">
                                    <a href="#">
                                        <img class="media-object img-rounded  question-media-left"
                                             th:src="${comment.user.avatarUrl}">
                                    </a>
                                </div>
                                <div class="media-body">
                                    <h5 class="media-heading">
                                        <span th:text="${comment.user.name}"></span>
                                    </h5>
                                    <div th:text="${comment.content}"></div>
                                    <div class="question-menu-icon">
                                        <div class="glyphicon glyphicon-thumbs-up question-icon"></div>

                                        <div class="glyphicon glyphicon-comment question-icon "
                                             onclick="collapseComments(this)" data-toggle="collapse"
                                             th:data-target="${'#comment-'+comment.id} " th:id="${comment.id}">
                                            <div class="question-icon-text" th:text="${comment.commentCount}">
                                            </div>
                                        </div>


                                        <span class="pull-right"
                                              th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd')}"></span>

                                    </div>


                                    <div class="collapse question-Secondary-review col-lg-12 col-md-12 col-sm-12 col-xs-12"
                                         th:id="${'comment-'+comment.id}">

                                        <!--评论输入框-->
                                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                            <input type="text" class="form-control" placeholder="评论一下..."
                                                   th:id="${'input-'+comment.id}">
                                            <button type="button" class="btn btn-success pull-right question-btn"
                                                    onclick="comment(this)" th:data-id="${comment.id}">评论
                                            </button>
                                        </div>

                                    </div>


                                </div>

                            </div>
                        </div>
                    </div>
                    <!--  回复输入框  -->
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-matter"
                         id="comment_section">
                        <div class="media question-media">
                            <div class="media-left pull-left">
                                <a href="#">
                                    <img class="media-object img-rounded "
                                         th:src="${session.user != null ? session.user.avatarUrl :'/imgs/default.png'}">
                                </a>
                            </div>
                            <div class="media-body">
                                <h5 class="media-heading">
                                    <span th:text="${session.user != null ? session.user.name : '匿名用户'}"></span>
                                </h5>
                            </div>
                        </div>
                        <input type="hidden" id="question_id" th:value="${question.id}">
                        <textarea class="form-control question-comment" rows="6" id="comment_content"></textarea>
                        <button type="button" class="btn btn-success question-btn" onclick="post()">回复</button>
                    </div>
                </div>


                <!-- 右边信息框-->
                <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12 question-border">

                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-border-div">
                        <h4>发起人</h4>
                        <div class="media question-media-right">
                            <div class="media-left">
                                <a href="#">
                                    <img class="media-object img-circle " th:src="${question.user.avatarUrl}">
                                </a>
                            </div>
                            <div class="media-body">
                                <h5 class="media-heading">
                                    <span th:text="${question.user.name}"></span>
                                </h5>
                            </div>
                        </div>
                    </div>

                    <hr class="question-hr">
                    <div th:insert="~{notice :: notice}"></div>

                    <!--相关问题-->
                    <hr class="question-hr">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 main-right">
                        <h4>相关问题</h4>
                        <ul class="question-related">
                            <li th:each="related : ${relatedQuestions}">
                                <a th:href="@{'/question/'+ ${related.id}}" th:text="${related.title}"></a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        </div>
        <div th:insert="~{footer :: foot}"></div>
    </body>
</html>